<template>
	<view class="floating-ball">
		<view class="ball" @tap="handelBall"></view>
		<view class="ball-bg" v-show="showBall" @tap="handelBall"></view>
		<!-- <view class="dhbg"></view> -->
		<view class="ball-menu-list" v-show="showBall" :class="showBallClass == true ? 'showBall' : 'hideBall'">
			<view class="ball-item" @tap="handelMenu(1)">
				<view class="img iconfont iconerweima_2">
				</view>
				<view class="title">二维码</view>
			</view>
			<view class="ball-item" @tap="handelMenu(2)">
				<view class="img img1 iconfont icongouwuche1">
				</view>
				<view class="title">购物车</view>
			</view>
			<view class="ball-item" @tap="handelMenu(3)">
				<view class="img img2 iconfont iconshoucang">
				</view>
				<view class="title">活动</view>
			</view>
			<view class="ball-item" @tap="handelMenu(4)">
				<view class="img iconfont icondianhua">
				</view>
				<view class="title">客服</view>
			</view>
		</view>
		<view class="qrcode-content" v-if="showQrcode == true" @tap="showQrcode = false">
			<view class="container" @tap.stop="">
				<view class="title">关注微信公众号</view>
				<view class="qrcode">
					
				</view>
				<view class="name">【智助教育】</view>
				<view class="tips">长按识别二维码，或保存添加</view>
				<view class="close-btn" @tap="showQrcode = false">确认</view>
				<view class="iconfont iconchahao" @tap="showQrcode = false"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showBall: false,
				showBallClass: false,
				showQrcode:false
			}
		},
		methods: {
			handelBall() {
				if (this.showBall == true) {
					this.showBallClass = false
					setTimeout(() => {
						this.showBall = !this.showBall
					}, 400)
				} else {
					this.showBallClass = true
					this.showBall = !this.showBall
				}
			},
			handelMenu(e) {
				if (e == 1) {
					this.showQrcode = true
				}
				let type = e == 1 ? 'qrCode' : e == 2 ? 'car' : e == 3 ? 'activity' : 'kefu'
				this.$emit('event',type)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.floating-ball {
		.ball {
			position: fixed;
			top: 76%;
			width: 80upx;
			height: 80upx;
			background-image: url(../../static/img/anniu.png);
			background-size: 100%;
			right: 30upx;
			z-index: 999;
		}

		.ball-bg {
			position: fixed;
			z-index: 900;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background-color: rgba(0, 0, 0, 0.5);
		}

		// .dhbg{
		// 	top: 66%;
		// 	left: 0;
		// 	position: fixed;
		// 	z-index: 98;
		// 	width: 100%;
		// 	height: 34%;
		// 	background-color: rgba(0, 0, 0, 0.1);
		// }
		.ball-menu-list {
			position: fixed;
			top: 76%;
			right: 34upx;
			margin-top: -506upx;
			height: 416upx;
			z-index: 998;

			.ball-item {
				width: 80upx;
				text-align: center;
				margin-top: 20upx;
				
				.img {
					margin: auto;
					width: 64upx;
					height: 64upx;
					background: #649BF4;
					border-radius: 50%;
					opacity: 1;
					text-align: center;
					font-size: 42upx;
					line-height: 64upx;
					color: #FFFFFF;
				}

				.img1 {
					background: #4EC38D;
				}

				.img2 {
					background: #FF9600;
				}

				.img3 {
					background: #FF5E56;
				}

				.title {
					text-align: center;
					font-size: 24upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					line-height: 30upx;
					margin-top: 10upx;
					color: #FFFFFF;
					opacity: 1;
				}
			}
		}
		.qrcode-content{
			position: fixed;
			width: 100%;
			height: 100%;
			top: 0;
			left: 0;
			z-index: 1000;
			background-color: rgba(0,0,0,0.5);
			.container{
				width: 600upx;
				height: 720upx;
				background-color: #FFFFFF;
				border-radius: 10upx;
				position: absolute;
				top: 50%;
				left: 50%;
				margin: -360upx 0 0 -300upx;
				.title{
					width: 100%;
					text-align: center;
					font-size: 32upx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					line-height: 48upx;
					color: #333333;
					opacity: 1;
					margin-top: 60upx;
				}
				.qrcode{
					width: 246upx;
					height: 242upx;
					background-color: #FAFAFA;
					margin: auto;
					margin-top: 70upx;
				}
				.name{
					margin-top: 50upx;
					width: 100%;
					text-align: center;
					font-size: 32upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					line-height: 48upx;
					color: #333333;
					opacity: 1;
				}
				.tips{
					width: 100%;
					text-align: center;
					font-size: 28upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					line-height: 40upx;
					color: #999999;
					opacity: 1;
					margin-top: 20upx;
				}
				.close-btn{
					width: 500upx;
					height: 70upx;
					text-align: center;
					background: #EAB868;
					border-radius: 35upx;
					font-size: 28upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					line-height: 70upx;
					color: #FFFFFF;
					opacity: 1;
					margin: auto;
					margin-top: 42upx;
				}
				.iconchahao{
					position: absolute;
					bottom: -80upx;
					font-size: 48upx;
					font-weight: 400;
					color: #FFFFFF;
					left: 50%;
					margin-left: -24upx;
				}
			}
		}
	}

	.hideBall {
		animation: hideBall 1s !important;
	}

	.showBall {
		animation: showBall 1s !important;
	}

	@keyframes showBall {
		from {
			top: 0%;
			height: 0;
			overflow: hidden;
		}

		to {
			top: 76%;
			height: 546upx;
			overflow: hidden;
		}
	}

	@keyframes hideBall {
		from {
			top: 76%;
			height: 546upx;
			overflow: hidden;
		}

		to {
			top: 0%;
			height: 0;
			overflow: hidden;
		}
	}
</style>
